# print(cu.getWmsStoregeStock("FTPLPB-0274","112","obj"))

#
# bill_list = cu.getTransBillList()
# bill_list = json.loads(bill_list)
# def getsalemapping(skulist):
#     url = cu.getApiList(cu.SALES_MAPPING_URL)
#     body = cu.getApiList(cu.SALES_MAPPING_PARA_BODY)
#     body["sellerSkuList"]=skulist
#     res = cu.getsalesmapping(url,body,1,200,[])
#     return res

# delete_redi_key()

tmpfile = "d:/tmp/long_text_2024-08-21-11-27-48.txt"
tempsql = "d:/tmp/tmp3.sql"
ressql = "d:/tmp/res.sql"
res = ""
count = 0


def init_data(tmpfile, ressql, count):
    with open(tmpfile, "r", encoding="utf-8") as filereader:
        res = ""
        with open(ressql, "w", encoding="utf-8") as filewriter:

            for line in filereader:
                for i in range(2):
                    index1 = line.find("(", i * 31)
                    index2 = line.find(",", index1)
                    substr = line[index1 + 1:index2 + 1]
                    print(substr)
                    line = line.replace(substr, "")
                # res += line
                count += 1;
                # if count >= 3:
                #     break
                line= line.replace(";","")
                line = line.replace("\n","")
                line = line + ( " ON DUPLICATE KEY UPDATE "
                        + "`in_transit_qty` = VALUES(`in_transit_qty`),"
                        +"`hold_qty` = VALUES(`hold_qty`),"
                        +"`use_qty` = VALUES(`use_qty`),"
                        +"`bad_qty` = VALUES(`bad_qty`),"
                        +"`bad_hold_qty` = VALUES(`bad_hold_qty`),"
                        +"`update_time` = VALUES(`update_time`); \n")
                filewriter.write(line)
        print(res)


init_data(tempsql, ressql, 0)
